<template>
  <div class="app-container">
    <el-form :inline="true" :model="formInline" ref="formInline" class="demo-form-inline">
      <el-form-item label="时间" prop="time">
      <el-date-picker
          v-model="formInline.time"
          type="datetimerange"
          align="right"
          unlink-panels
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          value-format="yyyy-MM-dd HH:mm:ss"
          :default-time="['00:00:00', '23:59:59']"
          :picker-options="pickerWeekStep">
      </el-date-picker>
    </el-form-item>
      <el-form-item class="with-pre-select" label="操作IP" prop="ip">
        <el-input v-model="formInline.ip" class="input-with-select" @keyup.enter.native="handleFilter">
        </el-input>
      </el-form-item>
      <el-form-item label="操作端" prop="clientType">
        <el-select v-model="formInline.clientType" placeholder="请选择操作端" >
          <el-option
            v-for="item in consts.DEVICE_TYPE"
            :label="item.title"
            :key="item.value"
            :value="item.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="操作项目" prop="operationType">
        <el-select v-model="formInline.operationType" placeholder="请选择操作项目">
          <el-option
            v-for="item in operatorList"
            :label="item.title"
            :key="item.value"
            :value="item.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-button class="filter-item" type="primary" icon="el-icon-search" @click="handleFilter">搜索</el-button>
      <el-button @click="cancel('formInline')">重置</el-button>
    </el-form>
  </div>

</template>

<script>
  import {form,pickerOption} from '@/build'

  export default {
    name: "form-operate-filter",
    mixins: [form,pickerOption],
    data() {
        // const {time, platform, ip, operationType} = formInline;
      return {
        operatorList:[],
        formInline: {
          time: [moment().startOf('month').format('YYYY-MM-DD 00:00:00'), moment().endOf('day').format('YYYY-MM-DD 23:59:59')],
          ip : '',
          operationType: '',
          clientType: '',
        },
      }
    },
    methods: {
      handleFilter() {
        this.$emit('on-filter', this.formInline)
      },
      cancel(formName) {
        this.resetForm(formName)
        this.handleFilter()
      },
      getContsData(){
        if(this.$route.name === 'member-list'){
          this.operatorList = consts.OPERATATION_TYPES;
        }
        if(this.$route.name === 'agency-list'){
          this.operatorList = consts.AGENCY_OPERATATION_TYPES;
        }
      }
    },
    created() {
      this.getContsData();
    },
    mounted(){
      // this.bindGet(getMemberOperatorSelect,'operatorList',{
      //   sendingData: {userId: this.$store.state.member.member_id}
      // })
      // this.getAll()
    },
  }
</script>

<style lang="scss" scoped>
  .with-pre-select {
    .el-input-group__prepend {
      .el-select {
        width: 120px;
      }
    }
  }

  .money-range {
    .el-input {
      width: 100px;
    }
  }

</style>
